{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d0ba4555-13a2-4242-a550-8790ae4f630c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "score is B.\n"
     ]
    }
   ],
   "source": [
    "score = 'B' \n",
    "match score:\n",
    "    case 'A': \n",
    "        print('score is A. ')\n",
    "    case 'B': \n",
    "        print('score is B.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "49abf3be-49f4-402d-ba33-e090dd803ed2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "11~ 15 years old.\n"
     ]
    }
   ],
   "source": [
    "age = 15 \n",
    "match age: \n",
    "    case x if x < 10:\n",
    "        print(f'< 10 years old : {x}')\n",
    "    case 10:\n",
    "        print('10 years old')\n",
    "    case 11 | 12 | 13 | 14 | 15:\n",
    "        print('11~ 15 years old.')\n",
    "    case _: \n",
    "        print('not sure.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f16be25e-1af5-41e8-95ab-6a6482302f36",
   "metadata": {},
   "outputs": [],
   "source": [
    "args = ['gcc', 'hello.c', 'world.c']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "f73de0c9-0faa-4bf1-824a-7e2b65ddda41",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "gcc compile: hello.c,world.c\n"
     ]
    }
   ],
   "source": [
    "match args: \n",
    "    case ['gcc']: \n",
    "        print('gcc: missing source file(s).')\n",
    "    case ['gcc', file1, *files]: \n",
    "        print('gcc compile: ' + file1 + ',' + ','.join(files))\n",
    "    case ['clean']:\n",
    "        print('clean')\n",
    "    case _: \n",
    "        print('invalid command.')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "80f4719c-85d9-4ff2-84b9-f7a6916778c8",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
